package com.hmall.search.listener;

import com.hmall.search.constant.MqConstant;
import com.hmall.search.service.SearchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class MqListener {
    @Autowired
    SearchService service;
    @RabbitListener(queues = MqConstant.HOTEL_DELETE_QUEUE)
    public void listenDelete(Long id){
        log.info("接收到删除的信息");
        service.deleteById(id);

    }
    @RabbitListener(queues = MqConstant.HOTEL_INSERT_QUEUE)
    public void listenInsert(Long id) {
        log.info("接受到了修改的消息{}",id);
        service.insertById(id);
    }


}
